/*
 * @Author: zhang zhijiang 2824735304@qq.com
 * @Date: 2024-12-09 21:25:13
 * @LastEditors: zhang zhijiang 2824735304@qq.com
 * @LastEditTime: 2024-12-09 22:02:52
 * @FilePath: /linux/test_12_9/comman.hpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include <iostream>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include<stdlib.h>
#include<unistd.h>
#define path "/home/zzj_1"
#define size 4096 
int proj_id = 5;
using namespace std;
int getkey()
{
    key_t k = ftok(path, proj_id);
    return k;
}

int create(int flag)
{
    int key = getkey();
    int shmid = shmget(key, size,flag );//创建共享内存
    if(shmid==-1)
    {
        perror("shmget");
        exit(1);
    }
    
    return shmid;
}
int getshmid()
{
    return create(IPC_CREAT);
}

